Mac OS 8.5 Technote: Part VIII

Copyright 1998 by Apple Computer, Inc. All Rights Reserved.

[Previous section] [Mac OS 8.5 Contents Page] [Next section]

Inside the System File

The System file contains code and resources for running the computer. This section describes new features, changes, and bug fixes in the System file. The functionality provided by the System file is always present under Mac OS 8.5, even when the shift key is held down at system startup.

General

  • In Mac OS 8.5, the emulated 68K processor runs in user mode even when VM is off. All 68K interrupt code runs in supervisor mode. As a result, all 68K interrupt code utilizes the interrupt stack pointer instead of the user stack pointer (the stack used by non-interrupt code). This change reduces the chance of the stack overrunning the application's heap zone during interrupt processing.

WARNING:
Developers should not assume the emulated 68K processor is running in supervisor mode when Virtual Memory is OFF.

Developers who require access to supervisor mode 68K instructions can use the _EnterSupervisorMode trap to switch the processor mode. The assembler code shown in Listing 1 illustrates the correct way to call the _EnterSupervisorMode trap and enter supervisor mode. Here, the result returned by DebuggerGetMax is examined to determine if _EnterSupervisorMode (selector 8) is available. If it is available, _EnterSupervisorMode is called.

Listing 1. The correct way to ensure the 68K processor is in supervisor mode.
; Is _DebugUtil available?
; Code running on a IIci or later can skip this step.
    move.w  #_Unimplemented,d0
    _GetToolTrapAddress
    move.l  a0,-(sp)
    move.l  #$A08D,d0         ; get _DebugUtil
    _GetToolTrapAddress
    cmpa.l  (sp)+,a0          ; was this previously
                              ; unimplemented?
    beq.s   @noEnterSupervisorMode
   
; Is the _EnterSupervisorMode selector available?
    _DebuggerGetMax           ; check how many _DebugUtil
                              ; selectors are implemented
    cmpi.l  #8,d0             ; is selector 8 available?
    blt.s   @noEnterSupervisorMode  ; EnterSupervisorMode isn't
                             ; available
   
    _EnterSupervisorMode     ; switch to supervisor mode
                             ; (switches stacks)
    move.w  d0,-(sp)         ; and save the previous SR contents
                             ; on the stack
    bra.s   @inSupervisorMode
   
; If _EnterSupervisorMode wasn't available, then put
; sr on the stack
@noEnterSupervisorMode
    move    sr,-(sp)         ; save the current SR
   
@inSupervisorMode
   
; ...
; do stuff in supervisor mode
; remember that the stack has been swapped if we switched
; from user mode to supervisor mode.
; ...
   
    move    (sp)+,sr         ; restore the SR

COMPATIBILITY NOTE
DebuggerGetMax is available on all machines supported by Mac OS 8.5. On other systems, developers must test for the _DebugUtil trap before calling DebuggerGetMax.Testing for VM to determine if the _EnterSupervisorMode trap should be used is considered a programming error: developers should use the above method instead.

  • Various managers, in particular Font Manager, are considerably less memory-hungry, both on a per-process and system-wide basis.

  • Several of the managers are now entirely implemented in PowerPC code.

  • The dialog informing the user that an improper shutdown occurred has been redesigned. It now includes an option to run Disk First Aid before continuing the startup process and will time out after two minutes.

    Related Materials:

[Previous section] [Mac OS 8.5 Contents Page] [Next section]

To contact us, please use the Contact Us page.